home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 10 / FM Towns Free Software Collection 10.iso / ms_dos / tool / fapxtool / src / txm / txmetc.c < prev    next >
C/C++ Source or Header  |  1994-11-18  |  2KB  |  94 lines

  1. /***************
  2. *
  3. * e:\usr\exe\txm\txmetc.c
  4. */
  5. #include "txm.h"
  6.  
  7.  
  8. int matchstr(char *form, char *txtptr)
  9. {
  10.     char *logtmp;
  11.     char *strtmp;
  12.     int i, trueflg = 0, count = 0;
  13.  
  14.     logtmp = txtptr;
  15.     strtmp = form;
  16.     while (*strtmp != NUL) {
  17.         trueflg = FALSE;
  18.         switch (*strtmp) {
  19.         case '%':
  20.             if (isdigit(*logtmp) || (*logtmp == ' ')) {
  21.                 trueflg = TRUE;
  22.             }
  23.             break;
  24.         case '*':
  25.             if (isalpha(*logtmp)) {
  26.                 trueflg = TRUE;
  27.             }
  28.             break;
  29.         case '&':
  30.             if (isalpha(*logtmp) || isdigit(*logtmp)) {
  31.                 trueflg = TRUE;
  32.             }
  33.             break;
  34.         case '_':
  35.             if (*logtmp == ' ') {
  36.                 trueflg = TRUE;
  37.             }
  38.             break;
  39.         case '$':
  40.             trueflg = TRUE;
  41.             break;
  42.         case 0x27:
  43.             strtmp++;
  44.             if (*logtmp == *strtmp) {
  45.                 trueflg = TRUE;
  46.             }
  47.             break;
  48.         case '^':
  49.             strtmp++;
  50.             count = ((*strtmp) - ('0'));
  51.             strtmp++;
  52.             while (trueflg != TRUE) {
  53.                 for (i = 0; i < count; i++) {
  54.                     if ((*(logtmp + i) != *(strtmp + i)) || (*(logtmp + i)
  55.                             == 0x0d)) {
  56.                         break;
  57.                     }
  58.                 }
  59.                 if (i != count) {
  60.                     logtmp++;
  61.                     if (*logtmp == 0x0a) {
  62.                         break;
  63.                     }
  64.                 }
  65.                 else {
  66.                     trueflg = TRUE;
  67.                 }
  68.             }
  69.             break;
  70.         default:
  71.             if (islower(*strtmp)) {
  72.                 if (tolower(*logtmp) == *strtmp) {
  73.                     trueflg = TRUE;
  74.                 }
  75.             }
  76.             else {
  77.                 if (*logtmp == *strtmp) {
  78.                     trueflg = TRUE;
  79.                 }
  80.             }
  81.         }
  82. /*        fprintf(stdout, "matchstr:%c,%c:", *strtmp, *logtmp);    */
  83.         if (trueflg != TRUE) {
  84. /*            puts("NG!");                                */
  85.             return (FALSE);
  86.         }
  87. /*        puts("GOOD!");                                    */
  88.         strtmp++;
  89.         logtmp++;
  90.     }
  91.     return (TRUE);
  92.  
  93. }
  94.